355A - Vasya and Digital Root - CodeForces Solution


constructive algorithms implementation *1100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>

#define ll long long
#define AHMADZERIE ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ln "\n"
#define reb(i, a, b) for(int i=a;i<=b;i++)
#define sq(a) a*a
#define enter(a, n) for(int i=0;i<n;i++){cin>>a[i];}
#define out(a, n) for(int i=0;i<n;i++){cout<<a[i];}
#define pb(a) push_back(a);
#define enterv(v) for(int &x:v){cin >>x;}
#define all(v) v.begin(), v.end()
#define cont continue
#define br break
#define F first
#define S second
using namespace std;
const ll N = 20000000;
ll dp[N];

int myAtoi(string s) {
    long long val = 0;
    bool ok = 0;
    int i = 0, n = s.size();
    while (i < n && s[i] == ' ') { i++; }
    if (i == n) { return 0; }
    if (s[i] == '-') {
        ok = 1;
        i++;
    } else if (s[i] == '+') {
        ok = 0;
        i++;
    }
    while (i < n && isdigit(s[i])) {
        val = 10 * val + (s[i] - '0');
        i++;
        if (val > 1e10) { break; }
    }
    if (ok) { val = -val; }
    if (val >= INT_MAX) { val = INT_MAX; }
    if (val <= INT_MIN) { val = INT_MIN; }
    return (int) val;
}

int main() {
    AHMADZERIE
    /*ll n;
    cin >> n;
    map<int,bool>mp;
    int arr[n];
    int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0, cnt6 = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        mp[arr[i]]= false;
        if (arr[i] < 0) {
            cnt1++;
            cnt4 = cnt1;
        }
        else if (arr[i] > 0) {
            cnt2++;
            cnt5 = cnt2;
        }
        else {
            cnt3++;
            cnt6 = cnt3;
        }
    }
    int arr1[n];
    int arr2[n];
    int arr3[n];
    int c1=0,c2=0,c3=0;
    if(cnt2==0){
        for (int i = 0; i < n; ++i) {
            if(c2==2){br;}
            if(arr[i]<0){
                arr2[c2]=arr[i];
                c2++;
            }
        }
    }*/
    int n, k;
    cin >> n >> k;
    if (k == 0 && n != 1) {
        cout << "No solution" << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (k > 0) {
            cout << k;
            k = 0;
        } else cout << 0;
    }
}


Comments

Submit
0 Comments
More Questions

501B - Misha and Changing Handles
1496A - Split it
1666L - Labyrinth
1294B - Collecting Packages
1642B - Power Walking
1424M - Ancient Language
600C - Make Palindrome
1669D - Colorful Stamp
1669B - Triple
1669A - Division
1669H - Maximal AND
1669E - 2-Letter Strings
483A - Counterexample
3C - Tic-tac-toe
1669F - Eating Candies
1323B - Count Subrectangles
991C - Candies
1463A - Dungeon
1671D - Insert a Progression
1671A - String Building
1671B - Consecutive Points Segment
1671C - Dolce Vita
1669G - Fall Down
4D - Mysterious Present
1316B - String Modification
1204A - BowWow and the Timetable
508B - Anton and currency you all know
1672A - Log Chopping
300A - Array
48D - Permutations